package com.bbs.user.impl;

import com.bbs.UserInfoMapper;
import com.bbs.UserRoleInfo;
import com.bbs.UserRoleInfoMapper;
import com.bbs.example.UserInfoExample;
import com.bbs.example.UserRoleInfoExample;
import com.bbs.model.UserParams;
import com.bbs.user.UserInfo;
import com.bbs.user.UserService_v2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl_v2 implements UserService_v2 {

    @Autowired
    UserInfoMapper userInfoMapper;
    @Autowired
    UserRoleInfoMapper userRoleInfoMapper;

    @Override
    public List<UserRoleInfo> getUserRoleInfos(String userCode) {
        UserRoleInfoExample userRoleInfoExample = new UserRoleInfoExample();
        userRoleInfoExample.createCriteria().andUSER_CODEEqualTo(userCode);
        List<UserRoleInfo> userRoleInfos = userRoleInfoMapper.selectByExample(userRoleInfoExample);
        return userRoleInfos;
    }

    @Override
    public List<UserInfo> getUserInfos(String username) {
        UserInfoExample userInfoExample = new UserInfoExample();
        userInfoExample.createCriteria().andUSER_NAMEEqualTo(username);
        List<UserInfo> userInfos = userInfoMapper.selectByExample(userInfoExample);
        return userInfos;
    }

    @Override
    public UserInfo login(UserParams userParams) {
        return userInfoMapper.login(userParams);
    }
}
